@extends('admin.base')
    @section('content')
        <!-- Content Header (Page header) -->
   <meta name="csrf-token" content="{{ csrf_token() }}">
        <section class="content-header">
          <h1>
            专家表
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 专家首页</a></li>
            <li><a href="#"> 专家信息</a></li>
            <li class="active">专家列表</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 专家信息</h3>
                            &nbsp; <button class="btn btn-sm btn-primary" onclick="window.location='{{URL('expert/create')}}'">添加专家</button
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered">
                    <tr>
                      <th>专家名称</th>
                      <th>专家技能</th>
                      <th>专家头像</th>
                              <th>医院</th>
                      <th>操作</th>
                    </tr>
                 @foreach($list as $v)
                    <tr>
                      <td>{{$v->name}}</td>
                      <td>{{$v->job}}</td>
                      <td><img style="width:30px;" src="uploads/{{$v->head_img}}"></td>
                                 <td>{{$v->hos_name}}</td>
                      <td>
                        @if($v->is_top ===1)
                      
                        <button onclick="doDelete({{$v->id}})" class="btn btn-xs btn-danger">已推荐</button> 
                        @else
                            <button onclick="doDel({{$v->id}})" class="btn btn-xs btn-danger">未推荐</button> 
                       @endif
                        
                        <button class="btn btn-xs btn-primary" onclick="window.location='{{URL('expert')}}/{{ $v->id }}/edit'">编辑</button></td>
                    </tr>
                   @endforeach
                  
                   
                  </table>
                </div><!-- /.box-body -->
                
              </div><!-- /.box -->

              
              
            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
        <form action="" style="display:none;" id="mydeleteform" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="_method" value="DELETE">
        </form>
    @endsection
    
    
    @section("myscript")
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="saveType()" class="btn btn-primary">保存</button>
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript">
        function doDel(id){
            Modal.confirm({msg:'是否确定推荐？'}).on(function (e){
                if(e){
                   $.ajax({
                     headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                      },
                      url:'{{url("is_top")}}',
                      data:{
                        id:id,
                      },
                      success:function(res){
                          alert('推荐成功');
                      }
                      
                   });
                }
            });
        }
        
       function doDelete(id){
           Modal.confirm({msg:'是否确定取消推荐？'}).on(function (e){
                if(e){
                   $.ajax({
                     headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                      },
                      url:'{{url("null_top")}}',
                      data:{
                        id:id,
                      },
                      success:function(res){
                          alert('取消推荐成功');
                      }
                      
                   });
                }
            });
       }
       
            
    </script>
    @endsection